#ifndef MYCHART_H
#define MYCHART_H

#include <QtCharts/QChart>
#include <QtCore/QTimer>
#include <QPointF>
#include <QDateTimeAxis>
#include <QDateTime>
#include <QTime>
#include <QLineSeries>

QT_CHARTS_BEGIN_NAMESPACE
class QSplineSeries;
class QValueAxis;
QT_CHARTS_END_NAMESPACE

QT_CHARTS_USE_NAMESPACE

//![1]
class MyChart: public QChart
{
    Q_OBJECT
public:
    MyChart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = {});
    virtual ~MyChart();


    bool  isExistPoint();
    void  DrawNewPoint(qreal value);
    void  DrawNewPointwithScrollOneTick(qreal value);
    void  DrawNewPointwithSetMaxRange(qreal value);
    void  setSerialColorAndWidth(const QColor &color,int w);
    void  setSunBreakingReferenceLine(qreal value);
    //滚动相关
    void scrollOneTick();
    void ScrollParaInit();
    /*
    void startAutoScroll(int interval);
    void stopAutoScroll();
    */
    //坐标范围
    void setAxisXRange(); //加引用 调用会出错啊
    void setAxisX_MaxRange();
    void setAxisYRange(qreal &min,qreal &max);
    /*坐标格子数*/
    void setAxisXTickCount(int);
    void setAxisYTickCount(int);
    /*最大值更新相关*/
    void MaxIncreaseOneTick();
    /*
    void startMaxAutoIncrease(int interval);
    void stopMaxAutoIncrease();
    */
    QDateTime setDateTime;  //画图的时候要用到
    QDateTime startDateTime;
    QDateTime endDateTime;
public slots:
    void handleTimeout();

private:
    //QTimer m_timer; 节省开销 单线程多个定时器处理起来太慢了
    QSplineSeries *m_series;
    QLineSeries   *Tass_series;
    QStringList m_titles;
    QDateTimeAxis *m_axisX;
    QValueAxis *m_axisY;
    bool ScrollModFlag; /*两种模式不可同时启用 滚动优先级最高（都启用时默认滚动模式）*/
    bool MaxAutoIncreaseModFlag;
    qint32 SecNumPerTick;
};
//![1]



#endif // MYCHART_H
